/****************************************************
          File Name:sem_getvalue.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 20 Sep 2014 07:00:20 PM CST
*****************************************************/

#include"posix_ipc.h"

int main(int argc, char *argv[])
{
    Usage(argc,"/sem",argv[0],argv[1]);

    sem_t *sem;
    int flag=0;
    int val;

    sem=sem_open(argv[1],flag);
    if(sem==SEM_FAILED)
        err("sem_open");
    
    if(sem_getvalue(sem,&val)==-1)
        err("sem_getvalue");

    printf("\"current\" semaphore is: %d\n",val);
    exit(EXIT_SUCCESS);
}
